#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
#include<stdlib.h>

int main()
{
  while(1)
  {
    pid_t id = fork();
    if(!id)
    {
      // 子进程
      printf("child process start,pid: %d\n", getpid());
      execl("usr/bin/ls", "ls", "-a", "-l", NULL);
      exit(1);
    }
    else 
    {
      // 父进程
      int status = 0;
      pid_t id = waitpid(-1, &status, 0);
      if(id > 0)
      {
        printf("wait success, exit code: %d\n", WEXITSTATUS(status));
      }
    }
  }
  return 0;
}
